/*
 * @Description: 指导内容弹窗
 * @Author: Zzt
 * @Date: 2022-12-22 14:16:52
 * @LastEditTime: 2023-02-07 17:30:42
 */

import { Button, Descriptions, Input, Modal, Space, Table, Tag } from 'antd';
import { ColumnsType } from 'antd/es/table';
import { byteConvert } from '@/utils';

const columns: ColumnsType = [
  {
    title: '序号',
    dataIndex: 'fileNo',
    align: 'center',
    key: 'fileNo'
  },
  {
    title: '附件名称',
    dataIndex: 'fileName',
    align: 'center',
    key: 'fileName'
  },
  {
    title: '格式',
    dataIndex: 'fileExt',
    align: 'center',
    key: 'fileExt'
  },
  {
    title: '附件大小',
    dataIndex: 'fileSize',
    align: 'center',
    key: 'fileSize',
    render: (size: number) => byteConvert(size)
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
    render: (_, record: any) => (
      <Space size="small">
        <a href={record.fileUrl} target={'_blank'} download rel="noreferrer">
          下载
        </a>
        <Button type="link" href={record.fileUrl} target={'_blank'}>
          浏览
        </Button>
      </Space>
    )
  }
];
// const dataSource = [{ id: 1, size: 40 }];
function Inspection(props: any) {
  const { visible, onClose, enclosure } = props;

  const onCancel = () => {
    onClose();
  };

  return (
    <Modal
      title="审核反馈详情"
      visible={visible}
      width={900}
      destroyOnClose
      onCancel={onCancel}
      footer={null}
    >
      <div>
        <Descriptions labelStyle={{ fontWeight: 'bold' }}>
          <Descriptions.Item label="检查单位" span={1}>
            {enclosure?.guidanceUnitName}
          </Descriptions.Item>
          <Descriptions.Item label="检查人" span={2}>
            {enclosure?.checkPersonName}
          </Descriptions.Item>
          <Descriptions.Item label="审核时间" span={3}>
            {enclosure?.checkTime}
          </Descriptions.Item>
          <Descriptions.Item label="审核结果" span={2}>
            {enclosure?.sendStatus === 4 ? (
              <Tag color="green">审核通过</Tag>
            ) : (
              <Tag color="red">审核不通过</Tag>
            )}
          </Descriptions.Item>
        </Descriptions>
        <Descriptions labelStyle={{ fontWeight: 'bold' }} layout="vertical">
          <Descriptions.Item label="审核说明" span={3}>
            <Input.TextArea disabled value={enclosure?.description}></Input.TextArea>
          </Descriptions.Item>
          <Descriptions.Item label="附件" span={3}>
            <Table
              columns={columns}
              dataSource={enclosure?.checkAttachmentJsonDTOS}
              style={{ width: '100%' }}
              bordered={true}
              size={'small'}
            ></Table>
          </Descriptions.Item>
        </Descriptions>
      </div>
    </Modal>
  );
}
export default Inspection;
